import React, { Component } from 'react'
import { Provider } from 'react-redux'
import { Button, message, Modal } from 'antd'
import store from '@/store/index' // 导入你的 Redux store
import Counter from '@/store/counter' // 导入连接了 Redux store 的组件

const styles = {
  color: 'red'
}

const handleClick2 = () => {
  message.success('成功了')
}

export default class Home extends Component {
  state = {
    isModalOpen: false
  }

  handleOk = () => {
    this.setState({
      isModalOpen: false
    })
    message.success('关闭了')
  }

  handleCancel = () => {
    this.setState({
      isModalOpen: false
    })
  }

  handleClick3 = () => {
    console.log(this)
    this.setState({
      isModalOpen: true
    })
  }

  handleClick1 = () => {
    message.error('这是错误消息')
  }

  render() {
    return (
      <div>
        <div style={styles}>这是Home 页面</div>

        <Provider store={store}>
          <Counter />
        </Provider>

        <Button onClick={this.handleClick1}>点击事件</Button>
        <br />
        <br />
        <Button onClick={handleClick2}>点击事件</Button>
        <Button onClick={this.handleClick3}>打开弹窗</Button>

        <Modal
          title="Basic Modal"
          open={this.state.isModalOpen}
          onOk={this.handleOk}
          onCancel={this.handleCancel}>
          <p>Some contents...</p>
          <p>Some contents...</p>
          <p>Some contents...</p>
        </Modal>
      </div>
    )
  }
}
